package com.jiehoo.ooqi;

import java.io.Serializable;

/**
 * Sort info, used in sort part of QL.
 */
public class Sort implements Serializable {
  private static final long serialVersionUID = -6391482608989997755L;

  /**
   * Sort field.
   */
  private Field field;

  /**
   * Sort order.
   */
  private boolean asc;

  public Sort() {
  }

  public Sort(String name, boolean asc) {
    this.field = new Field(name);
    this.asc = asc;
  }

  public Sort(Field field, boolean asc) {
    this.field = field;
    this.asc = asc;
  }

  public Field getField() {
    return field;
  }

  public void setField(Field field) {
    this.field = field;
  }

  public boolean isAsc() {
    return asc;
  }

  public void setAsc(boolean asc) {
    this.asc = asc;
  }

  public String toString() {
    return field + " " + (asc ? "asc" : "desc");
  }
}
